// 默认的开始场景
export const newGame = 'rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1'
export const promotTest = 'rnbqk3/ppppp2P/8/8/8/8/2PPPPPP/RNBQKBNR w KQq - 0 1'
export const ip = '127.0.0.1'
export const port = 36119


// 返回数组的最后一位
export const getLast = (list) => {
    return list[list.length - 1] || '';
}

// 返回数组的倒数第二个
export const getLastNext = (list) => {
    return list[list.length - 2] || '';
}

// 传入局面分 返回阈值 阈值+score 结果是0-100 0 代表黑胜 100代表白胜
export const getScorePercent = (score) => {
    let threshold = 0;
    score = parseFloat(score);
    console.log('score = ',score);
    if (score < 2.5 && score > -2.5) {
        threshold = 50;
    } else if (score >= 2.5 && score <= 5) {
        threshold = 65;
    } else if (score >= -5 && score <= -2.5) {
        threshold = 35;
    } else if (score > 5 && score <= 8) {
        threshold = 78;
    } else if (score >= -8 && score <= -5) {
        threshold = 22;
    } else if (score > 8) {
        threshold = 85;
    } else if (score < -8) {
        threshold = 15;
    }

    console.log("计算的进度条阈值为 ", threshold);
    let res =  score + threshold;
    if(res > 100) {
        res = 98;
    }else if (res <0) {
        res = 2;
    }
    return res;
}
